package me.wpf.DesignMode.singleton;

import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Description: 测试单例
 *
 * @author 王朋飞
 * @create 2019/5/6
 */
public class Boot {

    static final Integer THEARDNUM = 10000;

    public static void main(String[] args) throws InterruptedException {
        Set<Singleton1> set = new HashSet<>();
        ExecutorService e = Executors.newFixedThreadPool(THEARDNUM);
        for (int i = 0; i < THEARDNUM; i++) {
            e.execute(new Thread(new Runnable() {
                @Override
                public void run() {
                    Singleton1 instance1 = Singleton1.getInstance3();
                    System.out.println(Thread.currentThread().getName()+"---"+instance1.toString());
                    set.add(instance1);
                }
            }));
        }
        Thread.sleep(2000L);
        System.out.println("==================================================================");
        System.out.println(set.size());
        e.shutdownNow();
    }
}
